package com.dhsc.service.impl.yykh.slrkp;

import com.dhsc.domain.ywzx.yykh.slrpd.SlrpdVo;
import com.dhsc.domain.ywzx.yykh.slrpd.SlrtssxVo;
import com.dhsc.domain.yypt.LayuiTableVo;
import com.dhsc.domain.yypt.ResponseObject;
import com.dhsc.exception.MyException;
import com.dhsc.local.dao.yykh.slrkp.ISlrkpDao;
import com.dhsc.service.yykh.slrkp.ISlrkpService;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author HP
 * @date 2024/7/16 15:22
 */

@Service
@Slf4j
public class SlrkpServiceImpl implements ISlrkpService {

    @Autowired
    private ISlrkpDao slrkpDao;

    @Override
    public LayuiTableVo querySlrkpmxInfo(SlrpdVo s) {
        LayuiTableVo obj = new LayuiTableVo();
        try {
            List<SlrpdVo> list = slrkpDao.querySlrkpmxInfo(s);
            obj.setData(list);
            obj.setCount(list.size());
            obj.setCode(0);
            obj.setMsg("");
        }catch (Exception e){
            log.error("查询受理人考评出错",e);
            throw new MyException("查询受理人考评出错",e);
        }
        return obj;
    }

    @Override
    public LayuiTableVo querySlrtssxInfo(SlrtssxVo s) {
        LayuiTableVo obj = new LayuiTableVo();
        try {
            PageMethod.startPage(s.getPage(), s.getLimit());
            List<SlrtssxVo> list = slrkpDao.querySlrtssxInfo(s);
            PageInfo<SlrtssxVo> pageInfo = new PageInfo<>(list);
            obj.setData(list);
            obj.setMsg("");
            obj.setCount(pageInfo.getTotal());
            obj.setCode(0);
        }catch (Exception e){
            log.error("查询受理人特殊事项信息出错",e);
            throw new MyException("查询受理人特殊事项信息出错",e);
        }
        return obj;
    }

    @Override
    public ResponseObject queryGyxx(SlrtssxVo s) {
        ResponseObject obj = new ResponseObject();
        try {
            List<SlrtssxVo> list = slrkpDao.queryGyxx(s);
            obj.setData(list);
            obj.setStatus(200);
        }catch (Exception e){
            log.error("查询柜员信息出错",e);
            throw new MyException("查询柜员信息出错");
        }
        return obj;
    }

    @Override
    public ResponseObject saveSlrtssx(SlrtssxVo s) {
        ResponseObject obj = new ResponseObject();
        try {
            slrkpDao.saveSlrtssx(s);
            obj.setStatus(200);
        }catch (Exception e){
            log.error("保存受理人特殊事项信息出错",e);
            throw new MyException("保存受理人特殊事项信息出错");
        }
        return obj;
    }

    @Override
    public ResponseObject deleteSlrtssx(SlrtssxVo s) {
        ResponseObject obj = new ResponseObject();
        try {
            slrkpDao.deleteSlrtssx(s);
            obj.setStatus(200);
        }catch (Exception e){
            log.error("删除受理人特殊事项信息出错",e);
            throw new MyException("删除受理人特殊事项信息出错");
        }
        return obj;
    }
}
